#ifndef SPRITEANIMATOR_H
#define SPRITEANIMATOR_H

#include "core/Component.h"
#include "components/renderers/SpriteRenderer.h"

namespace SolidityEngine{

class SpriteAnimator : public Component
{
    //width and height of the spritesheet
    int _w,_h;
    float _fps;
    int _framecount;
    SpriteRenderer* _renderer;
    bool _looping;
    bool _playing;
    int _currentframe;
    int _range[2];

    public:
        SpriteAnimator();
        virtual ~SpriteAnimator();

        void SetSpritesheetSize(int columns, int rows);
        int GetFrameCount() const {return _framecount;};

        bool IsPlaying() const {return _playing;};

        void Loop(int startframe, int endframe);

        void Play(int startframe, int endframe);

    protected:
    private:
        virtual void _OnInterval(); // called when the owning gameObject receives and OnTick();
        virtual void _OnStart();
        virtual void _OnDestroy(){};// called when the owning gameObject is destroyed
        virtual void _OnCollision(const Collision_ptr& col){};
        virtual SpriteAnimator* _Clone();
};

}

#endif // SPRITEANIMATOR_H
